<html>
<head><meta charset="utf-8"><title>intercepting errors temporarily · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html">intercepting errors temporarily</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169294030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169294030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169294030">(Jun 29 2019 at 11:49)</a>:</h4>
<p>Is there a way to execute a certain function in some context that converts errors to <code>Result</code> or something? Hopefully it would not output anything to stdout/err either.</p>



<a name="169296288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169296288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169296288">(Jun 29 2019 at 12:56)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> I would look at compare mode for NLL transition</p>



<a name="169297439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169297439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169297439">(Jun 29 2019 at 13:31)</a>:</h4>
<p>It appears that compare mode simply passes through a flag which enables/disables error reporting – something I want to avoid doing as that would involve threading such information across entire trait machinery for an external project.</p>



<a name="169639708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169639708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169639708">(Jul 04 2019 at 11:16)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span> any solutions that do not involve passing a flag through the call stack?</p>



<a name="169639804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169639804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169639804">(Jul 04 2019 at 11:18)</a>:</h4>
<p>I don't see how you can avoid threading something through to represent the interceptor itself. Unless you wanted to put an interceptor into thread-local storage or something?</p>



<a name="169644468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169644468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169644468">(Jul 04 2019 at 12:36)</a>:</h4>
<p>well I was thinking more something like this:</p>
<div class="codehilite"><pre><span></span>let result: Result&lt;_, _&gt; = diagnostics::catch_errors(|| {
    ...
})
</pre></div>


<p>which could work if we’re representing errors as panics (it could also change some state in diagnostics code or something)</p>



<a name="169824236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169824236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169824236">(Jul 07 2019 at 19:57)</a>:</h4>
<p>You could overwrite the error emitter with one that just stores the error and reinstate the previous emitter afterwards</p>



<a name="169824256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/intercepting%20errors%20temporarily/near/169824256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/intercepting.20errors.20temporarily.html#169824256">(Jul 07 2019 at 19:57)</a>:</h4>
<p>Though the error counter will still increase I think</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>